Fix FunctionApprovalResponseContent to message mapping #7152
Merged
stephentoub merged 3 commits intodotnet:mainfrom Dec 15, 2025
Merged
Fix FunctionApprovalResponseContent to message mapping #7152stephentoub merged 3 commits intodotnet:mainfrom
stephentoub merged 3 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the FunctionInvokingChatClient where FunctionApprovalResponseContent items from messages with null MessageId were incorrectly split into separate FunctionCallContent messages instead of being grouped together. The issue stemmed from inconsistent dictionary key usage when tracking messages during the conversion process.
Key Changes:
- Added regression test to verify correct grouping behavior when MessageId is null
- Fixed dictionary key mismatch by using RequestMessage.MessageId consistently for lookup and storage
- Added logic to handle fallback MessageId substitution when seeding the dictionary
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientApprovalsTests.cs | Adds comprehensive regression test with detailed documentation explaining the null MessageId grouping bug and expected behavior |
| src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs | Fixes dictionary key inconsistency by computing effective keys that account for fallback MessageId substitution and using RequestMessage.MessageId consistently |
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
Show resolved
Hide resolved
Contributor
Author
|
@dotnet-policy-service agree |
Contributor
Author
|
Fixes #7153 |
stephentoub
approved these changes
Dec 15, 2025
Member
stephentoub
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the fix.
...ies/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientApprovalsTests.cs
Outdated
Show resolved
Hide resolved
…nctionInvokingChatClientApprovalsTests.cs
This was referenced Jan 13, 2026
Merged
Bump Microsoft.Extensions.Http.Resilience from 10.1.0 to 10.2.0
askpt/openfeature-dotnet-workshop#96
Closed
Closed
Merged
Merged
This was referenced Jan 14, 2026
Closed
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When FunctionApprovalResponseContent items from the same original message (with MessageId = null) are processed, they incorrectly get split into separate FunctionCallContent messages instead of being grouped together.
Root Cause: Key mismatch in ConvertToFunctionCallContentMessages:
Fix (2 changes in FunctionInvokingChatClient.cs):
This ensures all approvals from the same original message (whether MessageId is set or null) get properly grouped into a single FunctionCallContent message.
Microsoft Reviewers: Open in CodeFlow